//
//  PBMyDeputeCell.m
//  PBHomeDemo
//
//  Created by Playboy on 2018/1/16.
//  Copyright © 2018年 tmkj. All rights reserved.
//

#import "PBMyDeputeCell.h"

@interface PBMyDeputeCell ()
@property (weak, nonatomic) IBOutlet UIImageView *coverImageView;
@property (weak, nonatomic) IBOutlet UILabel *mainLabel;
@property (weak, nonatomic) IBOutlet UILabel *desLabel;
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;



@end

@implementation PBMyDeputeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)refreshWithModel:(PBMyDeputeModel *)model {
    [self.coverImageView sd_setImageWithURL:[NSURL URLWithString:model.houseOverview[@"cover"]] placeholderImage:nil];
    self.mainLabel.text = model.houseOverview[@"name"];
    self.desLabel.text = model.message;
    self.priceLabel.text = [NSString stringWithFormat:@"%@元/月",model.houseOverview[@"rent"]];
    NSString *dateStr = [self returndate:model.contactTime];
    NSString *type;
    if (model.contactTimeOption == 1) {
        type = @"全天";
    }else if (model.contactTimeOption == 2) {
        type = @"上午";
    }else if (model.contactTimeOption == 3) {
        type = @"下午";
    }else if (model.contactTimeOption == 4) {
        type = @"晚上";
    }
    if (model.state == 1) {
        self.timeLabel.text = [NSString stringWithFormat:@"预约时间：%@ %@",dateStr,type];
    }else {
        self.timeLabel.text = [NSString stringWithFormat:@"完成时间：%@ %@",dateStr,type];
    }
}

- (NSString *)returndate:(NSString *)num{
    NSString *str1=[NSString stringWithFormat:@"%@",num];
    int x=[[str1 substringToIndex:10] intValue];
    NSDate *date1 = (NSDate *)[NSDate dateWithTimeIntervalSince1970:x];
    NSDateFormatter *dateformatter=[[NSDateFormatter alloc]init];
    [dateformatter setDateFormat:@"yyyy-MM-dd"];
    return [dateformatter stringFromDate:date1];
}

@end
